<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Javascript Array to PHP Array:: It-Base</title>
    <script type="text/javascript">
    <?php
    if($_POST['load'] == "yes"){
    	$phpArray = $_POST['nodes'];
    	   	
    } 
    ?>
    </script>
    <script type="text/javascript">

    convertJsArrayToPhpArray = function( array, name, form ) {
        if ( typeof( form ) == 'string' ) {
            form = document.getElementById( form );
        }
        var hidden = null;
        for( index in array ) {
            hidden = document.createElement( 'input' );
            hidden.setAttribute( 'type', 'hidden' );
            hidden.setAttribute( 'name', name + '[' + index +']' );
            hidden.setAttribute( 'value', array[index] );
            form.appendChild( hidden );
        }
    }

    checkScript = function() {
        var myArray = { 0:  'hello',
                        1:  'there' };
        convertJsArrayToPhpArray( myArray, 'jsArray', 'myForm' );
    }
</script>
</head>
<body>

<form action="newfile.php" method="post" id="myForm">
    <input type="submit" value="click me" onclick="checkScript()" />
	<input type="hidden" name="load" value="yes" />
</form>

<p>
    To see it working, click the button, and, if you're using Firefox, press ctrl+a, right click anywhere on the page and select the "View selection source" from the context menu. If you're using IE, well, GET A REAL BROWSER. But take my word for it, it works in IE too...
</p>
</body>
</html>